package resp;

import lombok.Getter;
import java.util.Arrays;


//枚举
@Getter
public enum MyEnum {
    //1：举值
    RC200("200", "成功"),
    RC401("401", "登录超时");

    //2：构造
    private final String code;
    private final String msg;

    private MyEnum(String code,String msg){
        this.code = code;
        this.msg = msg;
    }

    //3：遍历
    public static MyEnum getEnum(String code){
        return Arrays.stream(MyEnum.values()).filter(a->a.getCode().equalsIgnoreCase(code)).findFirst().orElse(null);
    }

    public static void main(String[] args) {
        System.out.println(MyEnum.getEnum("200"));
    }
}
